<?php
/**
 * Created by PhpStorm.
 * User: yuanjie
 * Date: 15/10/23
 * Time: 下午2:31
 */
class MaintenanceCars extends Eloquent
{
    protected $table = "maintenance_cars";

    public static function getMaintenanceCarByToken($token){
        $car_token = CarTokens::where('token',$token)->select(array('car_id'))->first();
        if(!is_null($car_token)){
            $car_data = MaintenanceCars::where('id',$car_token->car_id)
                ->where('status',1)
                ->first();
            if(is_null($car_data)){
                return -3; //上门车不存在
            }else{
                return $car_data;
            }
        }else{
            return -2; //token不存在
        }
    }

}
